package com.catmiw.wyz;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import com.catmiw.wyz.util.ExcelUtils;

public class TestLibirong {

	public static String[] getRowData(Row row){
		String[] str=new String[8];
		for (int i=0;i<str.length;i++){
			Cell cell=row.getCell(i);
			if (i==1){
				str[i]=Integer.parseInt((int)cell.getNumericCellValue()+"")+"";
			} else {
				str[i]=cell.getStringCellValue();
			}
		}
		return str;
	}
	public static void test(){
		Workbook wb1=ExcelUtils.getWorkbook("E:\\TEMP\\李碧荣名单\\12年\\12月\\12.xls");
		Workbook wb2=ExcelUtils.getWorkbook("E:\\TEMP\\李碧荣名单\\12年\\12月\\12_1.1.xls");
		Sheet sheet2=wb2.getSheet("Sheet1");
		Sheet sheet1=wb1.getSheet("12");
		Workbook wb3=ExcelUtils.getWorkbook("E:\\TEMP\\李碧荣名单\\12年\\12月\\筛选201212.xls");
		Sheet sheet3=wb3.getSheet("Sheet1");
		
		String[][] data1=new String[3208][];
		for (int j=1;j<3209;j++){
			Row row1=sheet1.getRow(j);
			data1[j-1]=getRowData(row1);
		}	
		int count=0;
		for (int i=0;i<4270;i++){
			Row row2=sheet2.getRow(i);
			String data[]=getRowData(row2);
			boolean find=false;
			for (int j=0;j<3208;j++){
				if (data[0].equals(data1[j][0])&&data[2].equals(data1[j][2])){
					find=true;
					break;
				}
			}
			if (!find){
				Row row=sheet3.getRow(count);
				for (int j=0;j<8;j++){
					Cell cell=row.getCell(j);
					cell.setCellValue(data[j]);
				}
				System.out.println(++count+"\t"+data[0]);
			}
		}
		ExcelUtils.writeWorkbook(wb3, "E:\\TEMP\\李碧荣名单\\12年\\12月\\筛选201212.xls");
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		test();

	}

}
